package com.yc.thread;

public class Demo3 {

	public static void main(String[] args) {
		
		Thread t1 = new Thread(()->{
			for (int i = 0; i < 10; i++) {
				System.out.println(Thread.currentThread().getName() + i);
				try {
					Thread.sleep(200);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		},"下载");
		t1.start();
		

		Thread t2 = new Thread(()->{
			for (int i = 0; i < 10; i++) {
				System.out.println(Thread.currentThread().getName() + i);
				try {
					if(i==5) {
						// t2线程阻塞了
						t1.join();
					}
					Thread.sleep(200);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		},"播放音乐");
		t2.start();
		
		
		
	}
	
}
